package 华为OD机试B卷复用题.基础题;

import utils.MyUtil;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

public class HJ24_数列描述 {
    public static void main(String[] args) throws FileNotFoundException {
        Scanner in = new Scanner(new File("src/main/java/华为OD机试B卷复用题/基础题/input/24.txt"));
        MyUtil.START();
        Solution(in);
        MyUtil.END();
    }

    static void Solution(Scanner in) {
        String res = "1";
        for (int i = 0; i < 2; i++) {
            res = dfs(res);
        }
        System.out.println(res);
    }

    static String dfs(String str) {
        if (str.length() == 1) {
            return "1" + str;
        }
        StringBuilder sb = new StringBuilder();
        int num = 1;
        char pre = str.charAt(0);
        for (int i = 1; i < str.length(); i++) {
            char now = str.charAt(i);
            if (now == pre) {
                num++;
            } else {
                sb.append(num).append(pre);
                pre = now;
                num = 1;
            }
        }
        sb.append(num).append(pre);
        return sb.toString();
    }
}
